package calbs.socket.packaging;

import calbs.socket.pojo.req.ReqGetSoftUpdateVersionMsg;
import calbs.socket.pojo.resp.RespData;
import calbs.socket.pojo.resp.RespSoftUpdateVersionMsg;
import calbs.socket.tool.CHexConver;

/**
 * Created by Q on 2017/8/11.
 */
public class SoftUpdateVersionPackingImp implements PackagingI<RespSoftUpdateVersionMsg> {
    @Override
    public String analysisMsg(RespData<RespSoftUpdateVersionMsg> respData){
        RespSoftUpdateVersionMsg respSoftUpdateVersionMsg = respData.getBody();
        String content ="";
        if(respSoftUpdateVersionMsg==null){
        }else {
            int utcTime = respSoftUpdateVersionMsg.getUtcTime();
             content = CHexConver.integeroHexString(utcTime, 4);
            String newVersionCode = respSoftUpdateVersionMsg.getNewVersionCode();
            content = content + CHexConver.packagingStr(newVersionCode);
            String softAddress = respSoftUpdateVersionMsg.getSoftAddress();
            content = content + CHexConver.packagingStr(softAddress);
        }
        return PackingUtils.packing(respData.getBody(),content);
    }
}
